package cn.jolyoulu.adminweb.entity.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import cn.jolyoulu.cmnservice.entity.dto.TreeDTO;
import cn.jolyoulu.cmnservice.entity.po.SysMenu;

import java.util.Objects;

/**
 * @Author LuZhouJin
 * @Date 2023/3/16
 */
@Data
@Accessors(chain = true)
public class UserMenuVO extends TreeDTO<UserMenuVO> {

    /** 路由地址 */
    private String path;

    /** 组件路径 */
    private String component;

    /** 菜单名称 */
    private String name;

    /** 是否隐藏路由: 0否,1是 */
    private Boolean hidden;

    /** 菜单图标 */
    private String icon;

    /** 菜单层级 */
    private Integer treeLevel;

    /** meta */
    private Meta meta;



    public UserMenuVO(SysMenu sysMenu) {
        if (Objects.nonNull(sysMenu)){
            this.path = sysMenu.getPath();
            this.component = sysMenu.getComponent();
            this.treeLevel = sysMenu.getTreeLevel();
            this.name = sysMenu.getMenuName();
            this.hidden = sysMenu.getHidden() == 1;
            this.icon = sysMenu.getIcon();
            this.meta = new Meta(sysMenu.getMenuName());
        }
    }

    @Data
    @NoArgsConstructor
    private static class Meta{
        private String title;

        public Meta(String title) {
            this.title = title;
        }
    }
}
